package StringClass;

public class UsuallyClass {
    public static void main(String[] args) {
        // int length();
        String s1 = "abc";
        System.out.println(s1.length());//3
        System.out.println("-----------------------");

        //Char charAt(int index);
        String s2 = "abcde";
        System.out.println(s2.charAt(2)); //c
        System.out.println("-----------------------");

        //boolean isEmpty();
        String s3 = "";
        System.out.println(s2.isEmpty());//false
        System.out.println(s3.isEmpty());//true
        System.out.println("-----------------------");

        //String toUpperCase() and String toLowerCase();
        String s4 = "ABCDE";
        System.out.println(s2.toUpperCase());
        System.out.println(s4.toLowerCase());
        System.out.println("-----------------------");

        //String trim();
        String s5 = " hello world     ";
        String s6 = s5.trim();
        System.out.println(s5);
        System.out.println(s6);
        System.out.println("-----------------------");

        //boolean equls() and boolean equlsIgnoreCase();
        String s10 = "Helloworld";
        String s11 = "helloworld";
        System.out.println(s10.equalsIgnoreCase(s11));
        System.out.println(s5.equals(s6));
        System.out.println("-----------------------");

        //String concat();
        String s7 = "hello worl";
        String s8 = s7.concat("d");
        System.out.println(s7);
        System.out.println(s8);
        System.out.println("-----------------------");

        //int compareTo();
        System.out.println(s7.compareTo(s8)); //负数表示前面小于后面
        System.out.println("-----------------------");

        //String substring(int beginIndex) and String substring(int beginIndex,int endIndex)[beginIndex,endIndex);
        String s9 ="ABCDEFG";
        System.out.println(s9.substring(5));
        System.out.println(s9.substring(2, 5)); //从[2,5)左闭右开

    }

}
